home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-08-01 | 28.9 KB | 1,021 lines | [TEXT/KAHL] |
- /******************************************************************************
- CNeoDLOGDialog.c
-
- Subclass of CDialog that can be create from DLOG/DITL
- resources. The standard dialog items are represented
- by their closest TCL analogs.
-
- SUPERCLASS = CDialog
-
- Copyright © 1991 Symantec Corporation. All rights reserved.
- Copyright © 1992 NeoLogic Systems. All rights reserved.
-
-
- ******************************************************************************/
-
- #include "NeoTypes.h"
- #include "Constants.h"
- #include "Commands.h"
- #include "TBUtilities.h"
- #include <CList.h>
- #include <CCheckBox.h>
- #include <CRadioControl.h>
- #include <CIntegerText.h>
- #include <CIconPane.h>
- #include <CPaneBorder.h>
- #include <CRadioGroupPane.h>
- #include <CBartender.h>
- #include <CScrollBar.h>
- #include CNeoDatabaseH
- #include "CNeoPopupPane.h"
- #include "CNeoDialogText.h"
- #include "CNDPicture.h"
- #include "CNeoDLOGDialog.h"
- #include "CNDButton.h"
- #include "CNeoDemoApp.h"
- #include "CNeoDemoDoc.h"
- #include "CNDFilePicture.h"
- #include "CNeoDemoScrollPane.h"
- #include "CNDImage.h"
-
- #define SysFontFam ((short*) 0x0BA6)
- #define SysFontSize ((short*) 0x0BA8)
- #define LastSpExtra ((long*) 0x0B4C)
-
- #define kUserType 2 /* popup menu dialog ID */
- #define kPICTName 4
- #define ktextBy 9
- #define ktextDate 10
- #define kUserFilm 11
- #define ktextCatalog 12
- #define ktextKeywords 13
- #define kUserBody 14
- #define kUserFocal 15
- #define kUserFStop 16
- #define kUserExposure 17
- #define ksearchText 19
- #define kTextInfo 21 /* <picture#>/<max#> dialog ID */
- #define kUserLineDivider1 22
- #define kUserLineDivider2 23
- #define ksigPICT 24 /* signal flag picture dialog ID */
- #define kType 25 /* displays the type of the current picture */
-
- #define kTypePopupMenuID 20 /* type popup resource ID */
- #define kFilmPopupMenuID 21 /* film popup resource ID */
- #define kBodyPopupMenuID 22
- #define kFocalPopupMenuID 23
- #define kFStopPopupMenuID 24
- #define kExposurePopupMenuID 25
-
- typedef struct tItemList
- {
- short maxIndex;
- tDITLItem items[1];
-
- } tItemList, *tItemListPtr, **tItemListHndl;
-
- extern CBartender *gBartender;
-
- static void CollectUntil(char delimiter, StringPtr text, short *index,
- StringPtr returnStr);
-
- static short itemID; /* current dialog item ID during initialization */
-
- /******************************************************************************
- CNeoDLOGDialog
-
- Initialize a dialog window from DLOG/DITL resources.
- ******************************************************************************/
-
- CNeoDLOGDialog::CNeoDLOGDialog(short aDLOGid, CDesktop *anEnclosure, CDirector *aSupervisor)
- {
- Rect boundsRect;
- SignedByte savedState;
- Boolean makeScrollable;
- DialogTHndl dlogTemplate;
-
- CNeoApp::FNumWindowsOpen++;
-
- fStaticTextFont = fEditTextFont = geneva; /* use the system font */
- fStaticTextSize = fEditTextSize = 9; /* use TE's default size */
- fDefaultBorderPen = 1; /* default to border of 1 pixel */
-
-
- /* Get the DLOG resource template */
- FailNILRes(dlogTemplate = (DialogTHndl)GetResource('DLOG', aDLOGid));
-
- /* Get window size from the template */
- boundsRect = (**dlogTemplate).boundsRect;
-
- /* If the procID is documentProc or zoomDocProc then give the window */
- /* horizontal and vertical scroll bars and a size box. */
-
- procID = (**dlogTemplate).procID;
- makeScrollable = (procID == documentProc) || (procID == zoomDocProc);
-
- CDialog::INewDialog(&boundsRect, kNotVisible, procID, (**dlogTemplate).goAwayFlag, anEnclosure, aSupervisor);
- MakePanorama(makeScrollable, makeScrollable, makeScrollable);
-
- /* Get the DITL resource and create all the dialog items */
- AddDITLItems((**dlogTemplate).itemsID, 0);
-
- ((CNeoDemoDoc *)aSupervisor)->fBottomLine = boundsRect.bottom-boundsRect.top; /* full length */
- ChangeSize(macPort->portRect.right - macPort->portRect.left, ((CNeoDemoDoc *)aSupervisor)->fDivideLine -2);
-
- } /* CDialog::CNeoDLOGDialog */
-
- CNeoDLOGDialog::~CNeoDLOGDialog(void)
- {
- CNeoApp::FNumWindowsOpen--;
- }
-
- /******************************************************************************
- AddDITLItems
-
- Parse the DITL resource, and create the appropriate TCL panes.
- A separate method is called for each item type, so it is not usually
- necessary to override this method.
-
- ******************************************************************************/
-
- void CNeoDLOGDialog::AddDITLItems(short DITLid, long baseID)
- {
- tItemListHndl itemList = NULL;
- SignedByte savedState;
- short currIndex, maxIndex, dataSize;
- Boolean fDisabled;
- tDITLItem * ditlItem;
- short itemWidth, itemHeight;
- LongPt itemTopLeft;
- CView *enclosure;
- CPane *newItem;
-
- NEOTRYTO
- {
- /* Get the DITL item list */
- itemList = (tItemListHndl) GetResource('DITL', DITLid);
- FailNILRes(itemList);
-
- savedState = HGetState((Handle) itemList);
- HLockHi((Handle)itemList);
-
- maxIndex = (**itemList).maxIndex; /* index of last item in list */
- ditlItem = (**itemList).items; /* point to the first DITL item */
-
- /* iterate over all the items in the DITL resource */
- /* and create the TCL panes on the fly */
-
- for (currIndex = 0; currIndex <= maxIndex; currIndex++) {
- itemID = currIndex+1; /* file local variable for the various add routines */
-
- /* Is this item disabled? */
- fDisabled = ditlItem->itemType & itemDisable;
-
- /* Get size of the item, and the pad it for word */
- /* alignment if necessary */
-
- dataSize = ditlItem->itemLength;
- if (dataSize & 1)
- ++dataSize;
-
- /* Find the "best fit" enclosure for the new item */
-
- enclosure = FindEnclosingView(&ditlItem->itemRect);
-
- /* Get the dimensions for the new item */
-
- itemWidth = ditlItem->itemRect.right - ditlItem->itemRect.left;
- itemHeight = ditlItem->itemRect.bottom - ditlItem->itemRect.top;
-
- /* If the enclosure for the new item is not the dialog */
- /* itself, then we should transform the top left to the */
- /* enclosure's coordinates. Note that the item rect in */
- /* ditlItem is passed unmodified to the item creation */
- /* methods. */
-
- ((CPane*) enclosure)->WindToFrame(topLeft(ditlItem->itemRect),
- &itemTopLeft);
-
- /* Switch on the item type. We must strip off the */
- /* enable bit to do so. */
-
- switch(ditlItem->itemType & 0x7F)
- {
- /* User Items */
- case userItem:
- newItem = AddDITLUserItem(itemWidth, itemHeight, itemTopLeft.h,
- itemTopLeft.v, enclosure, ditlItem);
- break;
-
- /* Push Buttons */
- case ctrlItem + btnCtrl:
- newItem = AddDITLPushBtn(itemWidth, itemHeight, itemTopLeft.h,
- itemTopLeft.v, enclosure, ditlItem);
- break;
-
- /* Check boxes */
- case ctrlItem + chkCtrl:
- newItem = AddDITLCheckBox(itemWidth, itemHeight, itemTopLeft.h,
- itemTopLeft.v, enclosure, ditlItem);
- break;
-
- /* Radio Buttons */
- case ctrlItem + radCtrl:
- newItem = AddDITLRadioBtn(itemWidth, itemHeight, itemTopLeft.h,
- itemTopLeft.v, enclosure, ditlItem,
- currIndex + baseID + 1);
- break;
-
- /* 'CNTL' Resource Controls */
- case ctrlItem + resCtrl:
- newItem = AddDITLResControl(itemWidth, itemHeight, itemTopLeft.h,
- itemTopLeft.v, enclosure, ditlItem);
- fDisabled=TRUE; /* don't want clicks, initially */
- break;
-
- /* Static text */
- case statText:
- newItem = AddDITLStatText(itemWidth, itemHeight, itemTopLeft.h,
- itemTopLeft.v, enclosure, ditlItem);
- break;
-
- /* Edit text */
- case editText:
- newItem = AddDITLEditText(itemWidth, itemHeight, itemTopLeft.h,
- itemTopLeft.v, enclosure, ditlItem);
- break;
-
- /* Icons */
- case iconItem:
- newItem = AddDITLIcon(itemWidth, itemHeight, itemTopLeft.h,
- itemTopLeft.v, enclosure, ditlItem);
- break;
-
- /* Pictures */
- case picItem:
- newItem = AddDITLPicture(itemWidth, itemHeight, itemTopLeft.h,
- itemTopLeft.v, enclosure, ditlItem);
- break;
-
- default:
- newItem = NULL;
- break;
- }
-
- if (newItem)
- {
- /* Set the view ID of the new dialog item to its index in the DITL + */
- /* the base ID supplied by the caller. */
-
- newItem->SetID(currIndex + baseID + 1);
- if (fDisabled)
- /* +++ disable item? */;
- else
- {
- newItem->SetWantsClicks(TRUE);
- }
- }
-
- /* bypass C pointer arithmetic to point to next item */
- ditlItem = (tDITLItem *)(((long) ditlItem) + dataSize + (sizeof(*ditlItem) - sizeof(ditlItem->itemData)));
-
- }
- }
- NEOCLEANUP {
- if (itemList)
- HSetState((Handle) itemList, savedState);
- }
- NEOENDTRYTO;
-
- } /* CNeoDLOGDialog::AddDITLItems */
-
- /******************************************************************************
- FindEnclosingView
-
- Find the view that completely encloses the given rectangle. DITLs have
- no concept of nested items, but we can allow nested views to be specified
- by checking whether the rectangle of an new item is completely
- enclosed by the rectangle of any existing items.
- The rectangle is taken to be in Window coordinates.
- ******************************************************************************/
-
- typedef struct tEnclViewInfo
- {
- Rect boundsRect;
- CView *enclosingView;
-
- } tEnclViewInfo;
-
- static Boolean View_FindEnclosing(CView *view, long infoAddr)
- {
- CView *subview = NULL;
- tEnclViewInfo *viewInfo = (tEnclViewInfo*) infoAddr;
-
- /* first check if the current view encloses the rect */
- /* if it does, then check if any subview encloses it */
-
- if (view->Contains(topLeft(viewInfo->boundsRect)) &&
- view->Contains(botRight(viewInfo->boundsRect)))
- {
- if (view->itsSubviews)
- {
- subview = (CView*) view->itsSubviews->FirstSuccess1(View_FindEnclosing,
- infoAddr);
- }
-
- /* save the most specific view that encloses the rect, */
- /* either a subview of this view, or this view */
-
- if (!viewInfo->enclosingView) /* TCL 1.1.1 DLP 9/30/91 */
- viewInfo->enclosingView = subview? subview : view;
- return TRUE;
- }
- else return FALSE;
- }
-
- CView *CNeoDLOGDialog::FindEnclosingView(Rect *boundsRect)
- {
- CView *foundView = NULL;
- tEnclViewInfo viewInfo;
-
- if (itsSubviews)
- {
- viewInfo.boundsRect = *boundsRect;
- viewInfo.enclosingView = NULL;
- foundView = (CView*) itsSubviews->FirstSuccess1(View_FindEnclosing,
- (long) &viewInfo);
-
- /* If foundView is not nil, then some subview encloses */
- /* the rect. However, there may be a view nested within */
- /* foundView that completely encloses the rect. */
- /* viewInfo.enclosingView returns the best view */
-
- foundView = viewInfo.enclosingView;
- }
-
- /* if no subview was found that completely encloses boundsRect */
- /* then the enclosure defaults to the dialog itself */
-
- return foundView? foundView : itsPanorama;
-
- } /* CNeoDLOGDialog::FindEnclosingView */
-
- /******************************************************************************
- AddDITLPushBtn
-
- Add a button.
- ******************************************************************************/
-
- CPane *CNeoDLOGDialog::AddDITLPushBtn(short aWidth, short aHeight, short hEncl,
- short vEncl, CView *enclosure, tDITLItem *ditlItem)
- {
- CNDButton *btn;
- Str255 titleStr;
- // long cmd;
-
- /* make a copy of the button title */
-
- CopyPString(&ditlItem->itemLength, titleStr);
-
- // /* ask the bartender to parse this string for us. */
- // gBartender->ParseItemString(titleStr, &cmd);
-
- btn = new(CNDButton);
- btn->INewButton(aWidth, aHeight, hEncl, vEncl, titleStr, TRUE,
- pushButProc, enclosure, this);
- SetDefaultButton(btn);
- // btn->SetClickCmd(cmd);
-
- return btn;
-
- } /* CNeoDLOGDialog::AddDITLPushBtn */
-
- /******************************************************************************
- AddDITLRadioBtn
-
- Add a radio button.
- ******************************************************************************/
-
- CPane *CNeoDLOGDialog::AddDITLRadioBtn(short aWidth, short aHeight, short hEncl,
- short vEncl, CView *enclosure, tDITLItem *ditlItem,
- long anID)
- {
- CRadioControl *radio = new(CRadioControl);
-
- radio->INewRadioControl(aWidth, aHeight, hEncl, vEncl, &ditlItem->itemLength,
- TRUE, enclosure, enclosure);
-
- return radio;
-
- } /* CNeoDLOGDialog::AddDITLRadioBtn */
-
- /******************************************************************************
- AddDITLCheckBox
-
- Add a checkbox
- ******************************************************************************/
-
- CPane *CNeoDLOGDialog::AddDITLCheckBox(short aWidth, short aHeight, short hEncl,
- short vEncl, CView *enclosure, tDITLItem *ditlItem)
- {
- CCheckBox *check = new(CCheckBox);
-
- check->INewCheckBox(aWidth, aHeight, hEncl, vEncl, &ditlItem->itemLength,
- TRUE, enclosure, this);
-
- return check;
-
- } /* CNeoDLOGDialog::AddDITLCheckBox */
-
- /******************************************************************************
- AddDITLResControl
-
- Resource controls are not supported by this class.
- ******************************************************************************/
-
- CPane *CNeoDLOGDialog::AddDITLResControl(short aWidth, short aHeight, short hEncl,
- short vEncl, CView *enclosure, tDITLItem *ditlItem)
- {
- CNeoDemoScrollPane *scrollPane = new CNeoDemoScrollPane;
- FailNIL(scrollPane);
-
- scrollPane->IScrollPane(enclosure,this,aWidth,aHeight,hEncl,vEncl,
- sizFIXEDSTICKY, sizFIXEDSTICKY,1,0,0);
-
- scrollPane->itsHorizSBar->SetMaxValue(0); /* initially, no pictures to scroll */
- scrollPane->itsHorizSBar->SetValue(0); /* initially, no pictures to scroll */
- ((CNeoDemoDoc *)itsSupervisor)->fScrollObj = scrollPane;
- return ((CPane*)scrollPane);
-
- } /* CNeoDLOGDialog::AddDITLResControl */
-
- /******************************************************************************
- AddDITLStatText
-
- Add a static text item. If the item text begins with the character '@',
- it is considered an overloaded item and the rest of the text is passed
- to the AddOverloadedItem method.
- The text font and size are controlled by the fStaticTextFont and
- fStaticTextSize instance variables.
- ******************************************************************************/
-
- CPane *CNeoDLOGDialog::AddDITLStatText(short aWidth, short aHeight, short hEncl,
- short vEncl, CView *enclosure, tDITLItem *ditlItem)
- {
- CEditText *text;
- unsigned char length;
- Str255 itemText;
-
- /* first check for overloading of static text items */
- /* overloading is signalled by a first character of '@' */
-
- if ((* (char*) ditlItem->itemData) == '@')
- {
- length = Min(ditlItem->itemLength - 1, 255);
- BlockMove(((char*) ditlItem->itemData) + 1, &itemText[1], length);
- itemText[0] = length;
-
- return AddOverloadedItem(itemText, aWidth, aHeight, hEncl, vEncl, enclosure, ditlItem);
- }
- else
- {
- text = new(CEditText);
- text->IEditText(enclosure, this, aWidth, aHeight, hEncl, vEncl, sizFIXEDSTICKY, sizFIXEDSTICKY, -1);
- text->Specify(kNotEditable, kNotSelectable, kNotStylable);
-
- text->SetFontNumber(fStaticTextFont);
-
- text->SetFontSize(fStaticTextSize);
-
- if (ditlItem->itemLength)
- text->SetTextPtr((Ptr) ditlItem->itemData, ditlItem->itemLength);
-
- if(itemID == kTextInfo)
- ((CNeoDemoDoc *)itsSupervisor)->fTextInfo = text;
- else
- if(itemID == kType)
- ((CNeoDemoDoc *)itsSupervisor)->fTextType = text;
-
- return text;
- }
-
- } /* CNeoDLOGDialog::AddDITLStatText */
-
- /******************************************************************************
- AddDITLEditText
-
- Add an edit text item. The text font and size are controlled by the
- fEditTextFont and fEditTextSize instance variables.
-
- *******************************************************************************/
-
- CPane *CNeoDLOGDialog::AddDITLEditText(short aWidth, short aHeight, short hEncl,
- short vEncl, CView *enclosure, tDITLItem *ditlItem)
- {
- CNeoDialogText *text;
-
- text = new(CNeoDialogText);
-
- text->IDialogText(enclosure, this, aWidth, aHeight, hEncl, vEncl, sizFIXEDSTICKY, sizFIXEDSTICKY, -1);
-
- text->SetFontNumber(fEditTextFont);
- if (fEditTextSize > 0)
- text->SetFontSize(fEditTextSize);
-
- /* bug in CDLOGDialog - viewRect of text edit record is set from the current port
- text size. So have to force viewRect.bottom same as destRect.bottom.
- */
- (**(text->macTE)).viewRect.bottom=aHeight;
-
- if (ditlItem->itemLength)
- text->SetTextPtr((Ptr) ditlItem->itemData, ditlItem->itemLength);
-
- switch(itemID)
- {
- case kPICTName:
- text->SetFontSize(12); /* name is bigger */
- text->SetAlignment(teJustCenter);
- ((CNeoDemoDoc *)itsSupervisor)->fTextName = text;
- break;
-
- case ksearchText:
- text->Hide(); /* so tab skips this field when it's invis */
- text->showBorder(TRUE);
- ((CNeoDemoDoc *)itsSupervisor)->fSearchText = text;
- break;
-
- case ktextBy:
- ((CNeoDemoDoc *)itsSupervisor)->fTextBy = text;
- break;
-
- case ktextDate:
- ((CNeoDemoDoc *)itsSupervisor)->fTextDate = text;
- break;
-
- case ktextCatalog:
- ((CNeoDemoDoc *)itsSupervisor)->fTextCatalog = text;
- break;
-
- case ktextKeywords:
- ((CNeoDemoDoc *)itsSupervisor)->fTextKeywords = text;
- break;
- }
-
- return text;
-
- } /* CNeoDLOGDialog::AddDITLEditText */
-
- /******************************************************************************
- AddDITLIcon
-
- Add an icon
- ******************************************************************************/
-
- CPane *CNeoDLOGDialog::AddDITLIcon(short aWidth, short aHeight, short hEncl,
- short vEncl, CView *enclosure, tDITLItem *ditlItem)
- {
- CIconPane *icon;
-
- icon = new(CIconPane);
- icon->IIconPane(enclosure, this, hEncl, vEncl,
- sizFIXEDSTICKY, sizFIXEDSTICKY, ditlItem->itemData[0], TRUE);
-
- return icon;
-
- } /* CNeoDLOGDialog::AddDITLIcon */
-
- /******************************************************************************
- AddDITLPicture
-
- Add a picture
- ******************************************************************************/
-
- CPane *CNeoDLOGDialog::AddDITLPicture(short aWidth, short aHeight, short hEncl, short vEncl, CView *enclosure, tDITLItem *ditlItem)
- {
- Point pt;
- CPaneBorder * border;
- CNDPicture * pict;
- CNDFilePicture * fpict;
-
-
- if (itemID == ksigPICT) /* special item - handles click to show/hide lower portion */
- {
- FailNIL(pict = new(CNDPicture));
- pict->INDPicture(ditlItem->itemData[0], enclosure, this,
- aWidth, aHeight, hEncl, vEncl, sizFIXEDSTICKY, sizFIXEDSTICKY);
-
- ((CNeoDemoDoc *)itsSupervisor)->fSignal = pict;
-
- return pict;
- }
- else /* main Picture object */
- {
- FailNIL(fpict = new(CNDFilePicture));
- fpict->INDFilePicture(enclosure, this, aWidth, aHeight,
- hEncl, vEncl, sizFIXEDSTICKY, sizFIXEDSTICKY);
-
- fpict->UsePICT(ditlItem->itemData[0]); /* pass resource ID of PICT */
- border = new(CPaneBorder);
- border->IPaneBorder(kBorderFrame);
- border->SetPenSize(3, 3); /* thick border like scrapbook's */
- border->SetPattern(&qd.white); /* not seen till it gets a click */
-
- fpict->SetBorder(border);
-
- ((CNeoDemoDoc *)itsSupervisor)->fPictObj = fpict;
-
- return fpict;
- }
-
- } /* CNeoDLOGDialog::AddDITLPicture */
-
- CNeoPopupPane *CNeoDLOGDialog::makePopup(short aID, CView *aEnclosure, short aWidth, short aHeight, short aHEncl, short aVEncl, short aSpace)
- {
- short saveFont;
- short saveSize;
- CNeoPopupPane * popup;
-
- saveFont = *SysFontFam;
- saveSize = *SysFontSize;
- *SysFontFam = geneva;
- *SysFontSize = 9;
- *LastSpExtra = -1L; // Signal to flush font cache
-
- popup = new CNeoPopupPane;
- NeoFailNil(popup);
- popup->INeoPopupPane(aID, aEnclosure, this, aWidth, aHeight, aHEncl, aVEncl, aSpace);
-
- *SysFontFam = saveFont;
- *SysFontSize = saveSize;
- *LastSpExtra = -1L; // Signal to flush font cache
-
- return popup;
- }
-
- /******************************************************************************
- AddDITLUserItem
-
- Add a user item. User items are converted to simple bordered panes
- that use the fDefaultBorderPen thickness.
- 2 user items are line dividers.
- 1 user item is PICT border.
- 1 user item is place for popup menu.
- ******************************************************************************/
-
- CPane *CNeoDLOGDialog::AddDITLUserItem(short aWidth, short aHeight, short hEncl,
- short vEncl, CView *enclosure, tDITLItem *ditlItem)
- {
- CPane * pane = new(CPane);
- Rect margin;
- CPaneBorder * border;
- CNeoPopupPane * typePop;
-
- switch(itemID)
- {
- case kUserLineDivider2:
- ((CNeoDemoDoc *)itsSupervisor)->fDivideLine = ditlItem->itemRect.bottom;
- /* fall through is intentional */
-
- case kUserLineDivider1:
- pane->IPane(enclosure, this, aWidth, -1, hEncl, vEncl,
- sizFIXEDSTICKY, sizFIXEDSTICKY);
- border = new(CPaneBorder);
- border->IPaneBorder(kBorderFrame);
- border->SetPenSize(fDefaultBorderPen, fDefaultBorderPen);
-
- pane->SetBorder(border);
-
- break;
-
-
- case kUserType:
- typePop = makePopup(kTypePopupMenuID, enclosure, aWidth, aHeight, hEncl, vEncl, 5);
- pane = (CPane*)typePop;
- ((CNeoDemoDoc *)itsSupervisor)->fPopObj = typePop;
- break;
-
- case kUserFilm:
- typePop = makePopup(kFilmPopupMenuID, enclosure, aWidth, aHeight, hEncl, vEncl, 29);
- pane = (CPane*)typePop;
- ((CNeoDemoDoc *)itsSupervisor)->fPopFilm = typePop;
- break;
-
- case kUserBody:
- typePop = makePopup(kBodyPopupMenuID, enclosure, aWidth, aHeight, hEncl, vEncl, 25);
- pane = (CPane*)typePop;
- ((CNeoDemoDoc *)itsSupervisor)->fPopBody = typePop;
- break;
-
- case kUserFocal:
- typePop = makePopup(kFocalPopupMenuID, enclosure, aWidth, aHeight, hEncl, vEncl, 24);
- pane = (CPane*)typePop;
- ((CNeoDemoDoc *)itsSupervisor)->fPopFocal=typePop;
- break;
-
- case kUserFStop:
- typePop = makePopup(kFStopPopupMenuID, enclosure, aWidth, aHeight, hEncl, vEncl, 18);
- pane = (CPane*)typePop;
- ((CNeoDemoDoc *)itsSupervisor)->fPopFStop = typePop;
- break;
-
- case kUserExposure:
- typePop = makePopup(kExposurePopupMenuID, enclosure, aWidth, aHeight, hEncl, vEncl, 6);
- pane = (CPane*)typePop;
- ((CNeoDemoDoc *)itsSupervisor)->fPopExposure = typePop;
- break;
- }
-
- return pane;
-
- } /* CNeoDLOGDialog::AddDITLUserItem */
-
-
- /******************************************************************************
- AddOverloadedItem
-
- View types that have no direct dialog mgr analog may be added
- by overloading the static text item. The types support are:
-
- TYPE STATIC TEXT
- ---- -----------
-
- Any Pane resource @$ClassName$ResType$ResID
- e.g. @CPopupMenuPane$Popm$1000
- would create a CPopupMenuPane from the template in
- the resource 'Popm' 1000. The size and location
- of the pane are taken from the dialog item rect,
- not from the resource.
-
- CRadioGroupPane @RadioGroupPane
-
-
- CIntegerText @# must be first two characters
- To supply min and max values enter
- @#<min>#<max>,
-
- e.g. @#100#200 (see Demo.π.rsrc DITL 1026)
-
- CNeoDialogText/ constraints @!! - creates required field, no max length
- @!<num> - not required, max length is num
- e.g. @!10 max length is 10
- @!!<num> - required field with max length
- e.g. @!!10
-
- Other overloaded types may be created by overriding this method.
-
- ******************************************************************************/
-
- CPane *CNeoDLOGDialog::AddOverloadedItem(StringPtr itemText, short aWidth, short aHeight,
- short hEncl, short vEncl,
- CView *enclosure, tDITLItem *ditlItem)
- {
- Str255 numStr;
- short index;
-
- if (Length(itemText) == 0) return NULL;
-
- if (itemText[1] == '$') // Create from resource
- {
- ResType type;
- long resID;
- Str255 className;
- CPane *newPane;
- PaneTemp savedTemplate, *theTemp;
- Handle templateRes;
- SignedByte savedState;
-
- // collect the class name, resource type and ID
- index = 2;
- CollectUntil('$', itemText, &index, className);
- if (Length(className) == 0)
- return nil;
-
- ++index;
- CollectUntil('$', itemText, &index, numStr);
- if (Length(numStr) == 0)
- return nil;
-
- BlockMove(&numStr[1], &type, sizeof(type));
- ++index;
- CollectUntil(' ', itemText, &index, numStr);
- if (Length(numStr) == 0)
- return nil;
-
- StringToNum(numStr, &resID);
-
- // get the resource, save the location and size, then
- // restore it after the pane is created.
-
- templateRes = GetResource(type, resID);
- FailNILRes(templateRes);
- savedState = HGetState(templateRes);
- HNoPurge(templateRes);
-
- theTemp = *(PaneTemp**) templateRes;
- savedTemplate = **(PaneTemp**)templateRes;
- theTemp->width = aWidth;
- theTemp->height = aHeight;
- theTemp->hEncl = hEncl;
- theTemp->vEncl = vEncl;
-
- // now make the pane
-
- newPane = (CPane *)new_by_name(PtoCstr(className));
- if (!newPane) Failure(paramErr, excNewByNameFailed);
-
- newPane->IViewRes(type, resID, enclosure, this);
-
- HSetState(templateRes, savedState);
- **(PaneTemp**) templateRes = savedTemplate; /* TCL 1.1.1 DLP 9/18/91 */
-
- return newPane;
- }
- else if (itemText[1] == '#') // Create a CIntegerText
- {
- long min, max;
- CIntegerText *text = new CIntegerText;
-
- text->IIntegerText(enclosure, this, aWidth, aHeight, hEncl, vEncl,
- sizFIXEDSTICKY, sizFIXEDSTICKY, -1);
-
- text->SetFontNumber(fEditTextFont);
- if (fEditTextSize > 0)
- text->SetFontSize(fEditTextSize);
-
- index = 2;
- min = MINLONG;
- max = MAXLONG;
-
- CollectUntil('#', itemText, &index, numStr);
- if (Length(numStr)) StringToNum(numStr, &min);
-
- // check if string not exhausted and have another '#'
-
- if ((index < Length(itemText)) && (itemText[index] == '#'))
- {
- index++; // move past delimiter
- CollectUntil('#', itemText, &index, numStr);
- if (Length(numStr)) StringToNum(numStr, &max);
- }
- text->SpecifyRange(min, max);
-
- return text;
-
- }
- else if (itemText[1] == '!') // Create a CNeoDialogText with constraints
- {
- Boolean required = FALSE;
- short index = 2;
- long maxChars = MAXLONG;
-
- CNeoDialogText *text = new CNeoDialogText;
-
- text->IDialogText(enclosure, this, aWidth, aHeight,
- hEncl, vEncl,
- sizFIXEDSTICKY, sizFIXEDSTICKY, -1);
-
- text->SetFontNumber(fEditTextFont);
- if (fEditTextSize > 0)
- text->SetFontSize(fEditTextSize);
-
- // if next char is another '!', make this a required field
- if (itemText[2] == '!')
- {
- index++;
- required = TRUE;
- }
- // next text, if any, is max number of chars, no
- // trailing delimiter is required, just collect until end of string
- CollectUntil('!', itemText, &index, numStr);
- if (Length(numStr)) StringToNum(numStr, &maxChars);
-
- text->SetConstraints(required, maxChars);
-
- return text;
- }
- else if (EqualString(itemText, "\pRadioGroupPane", FALSE, FALSE))
- {
- CPaneBorder * border;
- CRadioGroupPane * group = new CRadioGroupPane;
-
- group->IRadioGroupPane(enclosure, this, aWidth, aHeight,
- hEncl, vEncl, sizFIXEDSTICKY, sizFIXEDSTICKY);
- border = new CPaneBorder;
- border->IPaneBorder(kBorderFrame);
- border->SetPenSize(fDefaultBorderPen, fDefaultBorderPen);
- group->SetBorder(border);
-
- return group;
- }
-
- return NULL;
-
- } /* CNeoDLOGDialog::AddOverloadedItem */
-
- static void CollectUntil(char delimiter, StringPtr text, short *index,
- StringPtr returnStr)
- {
- short i = *index;
- short limit = Length(text);
-
- Length(returnStr) = 0;
- while ((text[i] != delimiter) && (i <= limit)) {
- returnStr[ ++returnStr[0]] = text[i++];
- }
- if (i > limit) i = limit;
- *index = i;
-
- }
-
- /******************************************************************************
- ProviderChanged
-
- Respond to a change in a provider. All the dialog items are implicit
- providers to the dialog. When an item becomes the gopher, it will notify
- the dialog. If the gopher is a pane, the dialog will attempt to scroll
- it into view.
- ******************************************************************************/
-
- void CNeoDLOGDialog::ProviderChanged(CCollaborator *aProvider, long reason, void* info)
- {
- short index;
- short count;
-
- switch (reason) {
- case NeoDialogBordersChanged:
- ((CNeoDemoDoc *)itsSupervisor)->showBorders(*(Boolean *)info);
- break;
- }
-
- inherited::ProviderChanged(aProvider, reason, info);
- } /* CNeoDLOGDialog::ProviderChanged */
-
- void CNeoDLOGDialog::DoCommand(long theCommand)
- {
- Boolean pass = TRUE;
- CNDImage * image;
-
- switch (theCommand) {
- case cmdCut:
- pass = ((CNeoDemoDoc *)itsSupervisor)->doCutCopy(TRUE);
- break;
-
- case cmdCopy:
- pass = ((CNeoDemoDoc *)itsSupervisor)->doCutCopy(FALSE);
- break;
-
- case cmdPaste:
- pass = ((CNeoDemoDoc *)itsSupervisor)->doPaste();
- break;
- }
-
- if (pass)
- inherited::DoCommand(theCommand); /* pass it on */
- }
-
- /******************************************************************************
- DoKeyDown {OVERRIDE}
-
- Handle keypresses in a DialogText object. Keys that have a special meaning
- in a dialog (tab, return, enter, and Escape) are passed to itsSupervisor,
- all other keys are passed through to the superclass.
- ******************************************************************************/
-
- void CNeoDLOGDialog::DoKeyDown(char theChar, Byte keyCode, EventRecord *macEvent)
- {
- if (theChar == '\t')
- ((CNeoDemoDoc *)itsSupervisor)->showBorders(TRUE);
-
- inherited::DoKeyDown(theChar, keyCode, macEvent);
-
- } /* CNeoDLOGDialog::DoKeyDown */
-
- Boolean CNeoDLOGDialog::isZoomed(void)
- {
- return ((CNeoDemoDoc *)itsSupervisor)->fSignal->isZoomed();
- }
-
- /******************************************************************************
- Update
-
- Update the contents of a window
- ******************************************************************************/
-
- void CNeoDLOGDialog::Update()
- {
- CNeoDatabase * database = gNeoDatabase;
- CNeoDemoDoc * document = (CNeoDemoDoc *)itsSupervisor;
-
- if (document->itsFile)
- gNeoDatabase = (CNeoDatabase *)document->itsFile;
- #ifdef qNeoDebug
- else
- NeoAssert(FALSE);
- #endif
-
- inherited::Update();
-
- gNeoDatabase = database;
- }
-
-